package com.sfac.hqyj.springBoot.modules.common.entity;

import org.apache.commons.lang3.StringUtils;

/*
此类用于分页
 */
public class SearchBean {
    //第一页
    public final static int DEFAULT_CURRENT_PAGE =1;
    //每页最多几条数据
    public final static int DEFAULT_PAGE_SIZE =5;

    private int currentPage;//当前页面
    private int pageSize;//每页几条数据
    private String keyWord;
    private String orderBy;
    private String direction;//排序
    public void initSearchBean() {
        if (this.getCurrentPage() == 0) {
            this.setCurrentPage(DEFAULT_CURRENT_PAGE);
        }
        if (this.getPageSize() == 0) {
            this.setPageSize(DEFAULT_PAGE_SIZE);
        }
        if (StringUtils.isBlank(this.getDirection())) {
            this.setDirection("desc");
        }
    }

    public static int getDefaultCurrentPage() {
        return DEFAULT_CURRENT_PAGE;
    }

    public static int getDefaultPageSize() {
        return DEFAULT_PAGE_SIZE;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public String getKeyWord() {
        return keyWord;
    }

    public void setKeyWord(String keyWord) {
        this.keyWord = keyWord;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public String getDirection() {
        return direction;
    }

    public void setDirection(String direction) {
        this.direction = direction;
    }
}
